/*
 * KineticProblem.h
 *
 *  Created on: 18 Oct 2011
 *      Author: allan
 */

#ifndef KINETICPROBLEM_H_
#define KINETICPROBLEM_H_

// C++ includes
#include <string>
#include <vector>
using namespace std;

// Eigen includes
#include <Eigen/Core>
using namespace Eigen;

// GeoReact includes
#include "Core/Multiphase.h"
#include "Core/ReactionSystem.h"
#include "Core/TotalEquilibriumSolver.h"
#include "Numerics/OdeSolver.h"

class KineticProblem : public OdeProblem
{
public:
	KineticProblem();
	
	KineticProblem(const Multiphase& multiphase, const ReactionSystem& eReactions, const ReactionSystem& kReactions, 
		const vector<string>& jSpecies,const vector<string>& eSpecies,const vector<string>& kSpecies);
	
	void Initialiaze(const Multiphase& multiphase, const ReactionSystem& eReactions, const ReactionSystem& kReactions, 
		const vector<string>& jSpecies,const vector<string>& eSpecies,const vector<string>& kSpecies);
	
	void SetParameters(double T, double P, const VectorXd& n);
	
	virtual void Function(double t, const VectorXd& ujnk, VectorXd& R);
	
private:
	/// The multiphase object responsible to compute the activities
	Multiphase multiphase;
	
	/// The equilibrium-controlled reactions
	ReactionSystem eReactions;

	/// The kinetically-controlled reactions
	ReactionSystem kReactions;
	
	/// The total equilibrium solver
	TotalEquilibriumSolver eSolver;
	
	/// The temperature (T) and pressure (P)
	double T, P;
	
	/// The composition of the species
	VectorXd n;
	
	/// The number of primary (Nj) and kinetic (Nk) species
	unsigned Nj, Nk;
	
	/// The indexes of the kinetic species (kIndexes)
	vector<Index> kIndexes;
	
	/// The stoichiometric matrices (ukj) and (ukk)
	MatrixXd ukj, ukk;
};

#endif /* KINETICPROBLEM_H_ */
